package com.manman.eduService.controller;


import com.manman.commonUtils.Result;
import com.manman.eduService.entity.subject.OneSubject;
import com.manman.eduService.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-01-29
 */
@RestController
@CrossOrigin
@RequestMapping("/eduService/subject")
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    // 添加课程分类
    // 获取上传过来文件，把文件内容读取出来
    @PostMapping("addSubject")
    public Result addSubject(MultipartFile file){
        // 上传过来的 excel 文件
        subjectService.saveSubject(file, subjectService);
        return Result.ok();
    }

    // 课程分类列表（树形）
    @GetMapping("getAllSubject")
    public Result getAllSubject(){
        List<OneSubject> list = subjectService.getAllSubject();
        return Result.ok().data("list", list);
    }

}

